package br.com.iswe.gwt.util.client;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.user.client.rpc.AsyncCallback;

public class CallBackList implements AsyncCallback {

	private List listaCallBacks = new ArrayList();

	public void onFailure(Throwable caught) {
		//varre a lista de callacks e executa
		for (int i = 0; i < listaCallBacks.size(); i++) {
			AsyncCallback callBack = (AsyncCallback)listaCallBacks.get(i);
			callBack.onFailure(caught);
		}
	}

	public void onSuccess(Object result) {
		//varre a lista de callacks e executa
		for (int i = 0; i < listaCallBacks.size(); i++) {
			AsyncCallback callBack = (AsyncCallback)listaCallBacks.get(i);
			callBack.onSuccess(result);
		}
	}
	
	public void add(AsyncCallback callBack){
		listaCallBacks.add(callBack);
	}	
}
